From: Shinjiman Date: Fri, 24 Jul 2009 18:35:09 +0000 (+0000) Subject: fix E_NOTICE on r53720 and r53721. X-Git-Tag: 1.31.0-rc.0~40739 X-Git-Url: http://git.cyclocoop.org/%22.%24match%5B1%5D.%22?a=commitdiff_plain;h=a68af638f5d093ab93b92ea94fb7720752d782ad;p=lhc%2Fweb%2Fwiklou.git fix E_NOTICE on r53720 and r53721. --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 48638bd418..bf3c33f614 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3195,15 +3195,20 @@ function wfObjectToArray( $object, $recursive = true ) { function wfBCP47( $code ) { $codeSegment = explode( '-', $code ); foreach ( $codeSegment as $segNo => $seg ) { - // ISO 3166 country code - if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) - $codeBCP[$segNo] = strtoupper ( $seg ); - // ISO 15924 script code - else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) - $codeBCP[$segNo] = ucfirst( $seg ); - // Keep casing for other cases - else + if ( count( $codeSegment ) > 0 ) { + // ISO 3166 country code + if ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) + $codeBCP[$segNo] = strtoupper ( $seg ); + // ISO 15924 script code + else if ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) + $codeBCP[$segNo] = ucfirst( $seg ); + else + // Keep casing for other cases + $codeBCP[$segNo] = $seg; + } else { + // Keep casing for single segment $codeBCP[$segNo] = $seg; + } } $langCode = implode ( '-' , $codeBCP ); return $langCode;